package com.wty.cmims.controller;

import com.wty.cmims.pojo.Department;
import com.wty.cmims.pojo.ResponseResult;
import com.wty.cmims.service.DepartmentService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/department")
@Tag(name = "科室信息", description = "社区医疗信息后台管理系统api接口")
public class DepartmentController {
    @Autowired
    private DepartmentService departmentService;

    // 科室获取（不分页）
    @PostMapping("/findDepartment")
    @Operation(summary = "科室获取（不分页）", description = "科室获取（不分页）")
    @Parameter(name = "paramsMap",description = "参数列表")
    @ApiResponse(description = "处理结果",content = {
            @Content(
                    mediaType="application/json",
                    schema= @Schema(implementation = ResponseResult.class)
            )
    })
    public ResponseResult<Map<String, Object>> departmentFind(@RequestBody Map<String,Object> paramsMap){
        return departmentService.departmentFind(paramsMap);
    }

    // 科室获取（分页）
    @PostMapping("/findDepartments")
    @Operation(summary = "科室获取（分页）", description = "科室获取（分页）")
    @Parameter(name = "paramsMap",description = "参数列表")
    @ApiResponse(description = "处理结果",content = {
            @Content(
                    mediaType="application/json",
                    schema= @Schema(implementation = ResponseResult.class)
            )
    })
    public ResponseResult<Map<String, Object>> departmentsFind(@RequestBody Map<String,Object> paramsMap){
        return departmentService.departmentsFind(paramsMap);
    }

    // 修改科室
    @PutMapping("/updateDepartment")
    @Operation(summary = "修改科室", description = "修改科室")
    @Parameter(name = "Department",description = "科室")
    @ApiResponse(description = "处理结果",content = {
            @Content(
                    mediaType="application/json",
                    schema= @Schema(implementation = ResponseResult.class)
            )
    })
    public ResponseResult<Void> departmentUpdate(@RequestBody Department department){
        return departmentService.departmentUpdate(department);
    }

    // 添加科室
    @PostMapping("/addDepartment")
    @Operation(summary = "添加科室", description = "添加科室")
    @Parameter(name = "Department",description = "科室")
    @ApiResponse(description = "处理结果",content = {
            @Content(
                    mediaType="application/json",
                    schema= @Schema(implementation = ResponseResult.class)
            )
    })
    public ResponseResult<Void> addDepartment(@RequestBody Department department){
        return departmentService.departmentAdd(department);
    }
}